package com.gw.detail.controllor.detail;

import com.gw.detail.domain.Fgdat;
import com.gw.detail.service.IFgdatService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 行人数据Controller
 *
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/fgdat")
public class FgdatController extends BaseController {
    @Autowired
    private IFgdatService fgdatService;

    /**
     * 查询行人数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:fgdat:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fgdat fgdat) {
        startPage();
        List<Fgdat> list = fgdatService.selectFgdatList(fgdat);
        return getDataTable(list);
    }

    /**
     * 导出行人数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:fgdat:export')")
    @Log(title = "行人数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Fgdat fgdat) {
        List<Fgdat> list = fgdatService.selectFgdatList(fgdat);
        ExcelUtil<Fgdat> util = new ExcelUtil<Fgdat>(Fgdat.class);
        return util.exportExcel(list, "行人数据数据");
    }

    /**
     * 获取行人数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:fgdat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(fgdatService.selectFgdatById(id));
    }

    /**
     * 新增行人数据
     */
    @PreAuthorize("@ss.hasPermi('detail:fgdat:add')")
    @Log(title = "行人数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fgdat fgdat) {
        return toAjax(fgdatService.insertFgdat(fgdat));
    }

    /**
     * 修改行人数据
     */
    @PreAuthorize("@ss.hasPermi('detail:fgdat:edit')")
    @Log(title = "行人数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fgdat fgdat) {
        return toAjax(fgdatService.updateFgdat(fgdat));
    }

    /**
     * 删除行人数据
     */
    @PreAuthorize("@ss.hasPermi('detail:fgdat:remove')")
    @Log(title = "行人数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(fgdatService.deleteFgdatByIds(ids));
    }
}
